﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBSchemaReader;

namespace DTOTemplatedGenerator.ViewModels
{
	internal class DatabaseExplorerViewModel: BaseVM
	{
		ISchemaReader _schemaReader;

		public DatabaseExplorerViewModel()
		{
			_schemaReader = SchemaReaderFactory.CreateSchemaReader();
		}

		public string DataSource
		{
			get
			{
				return _schemaReader.DataSource;
			}
			set
			{
				if (_schemaReader.DataSource != value)
				{
					_schemaReader.DataSource = value;
					this.OnPropertyChanged("ServerName");
				}
			}
		}

		public string DatabaseName
		{
			get
			{
				return _schemaReader.DatabaseName;
			}
			set
			{
				if (_schemaReader.DatabaseName != value)
				{
					_schemaReader.DatabaseName = value;
					this.OnPropertyChanged("DatabaseName");
				}
			}
		}

		public void RefreshTables()
		{
			var tables = _schemaReader.GetTablesInfo();
		}
	}
}
